turns out one can remove existing constraints on each subview of the toolbar and replace them such that those that were hidden will appear in there proper positions. and yes, I know this is frowned upon, but desperation drives me. this is my Swift 4.0 version of such code. it uses a third-party framework called SnapKit, which is simpler for me for constructing constraints:
var x = 7.0
for tool in subviews {
let y = tool.isHidden ? -3.0 : -8.0
tool.removeConstraints(tool.constraints)
tool.snp.makeConstraints { make in
make.left.equalToSuperview().offset(x)
make.bottom.equalToSuperview().offset(y)
}
x += tool.bounds.width + 3.0
tool.isHidden = false
}
Topic:
App & System Services
SubTopic:
General
Tags: